home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Complementary Applications 2004 May / SGI IRIX 6.5 Complementary Applications 2004 May.iso / dist / OpenOffice.idb / usr / OpenOffice / help / en / sbasic.jar / text / sbasic / common / 03120301.xml < prev    next >
Encoding:
Extensible Markup Language  |  2002-01-24  |  8.0 KB  |  76 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <html><head><title>Format Function [Runtime]</title><meta name="filename" content="text/sbasic/common/03120301"/><meta name="language" content="en-US"/><help:css-file-link xmlns:help="http://openoffice.org/2000/help"/><!--The CSS style header method for setting styles--><style type="text/css">
  3.  
  4.         table.Tabelle1{
  5.                 }
  6.         span.Tabelle1A{
  7.                 width:1.499cm;}
  8.         span.Tabelle1B{
  9.                 width:16.498cm;}
  10.         tr.Tabelle11{
  11.                 }
  12.         td.Tabelle1A1{
  13.                 }
  14.         p.P1{
  15.                 }
  16.         p.P2{
  17.                 }
  18.         span.T1{
  19.                 font-weight:bold;}
  20.         span.fr1{
  21.                 }
  22.         </style></head><body>
  23.   
  24.   
  25.   <help:to-be-embedded Eid="format" xmlns:help="http://openoffice.org/2000/help">
  26.   <p class="Head1"><help:link Id="66579">Format Function [Runtime]</help:link></p>
  27.   <p class="Paragraph">Converts a number to a string and formats it according to a format code.</p>
  28.   </help:to-be-embedded>
  29.   <table><tr class="Tabelle11"><th class="Tabelle1A1" style="text-align:left;"><span class="Tabelle1A">
  30.       <p class="TextInTable"><draw:image draw:style-name="fr1" draw:name="HIND_1" text:anchor-type="paragraph" svg:width="0.847cm" svg:height="0.847cm" draw:z-index="0" xlink:href="65980" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" draw:filter-name="GIF - Graphics Interchange" xmlns:draw="http://openoffice.org/2000/drawing" xmlns:text="http://openoffice.org/2000/text" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"/></p>
  31.      </span></th><th class="Tabelle1A1" style="text-align:left;"><span class="Tabelle1B">
  32.       <p class="TextInTable">If the number is defined as a String, no type conversion will be executed, and the result will be an empty string.</p>
  33.      </span></th></tr></table>
  34.   <p class="Paragraph"/>
  35.   <p class="Paragraph"><span class="T1">Syntax</span>:</p>
  36.   <p class="Paragraph">Format (Number [, Format As String]) <help:key-word value="Format" tag="kw66579_1" xmlns:help="http://openoffice.org/2000/help"/></p>
  37.   <p class="Paragraph"><span class="T1">Return value</span>:</p>
  38.   <p class="Paragraph">String</p>
  39.   <p class="Paragraph"><span class="T1">Parameter</span>:</p>
  40.   <p class="Paragraph">Number: Numeric expression to be converted to a formatted string.</p>
  41.   <p class="Paragraph">Format: String that specifies the format code for the number. If <span class="T1">Format</span> is omitted, the Format function works like the <span class="T1">Str</span> function.</p>
  42.   <p class="Paragraph">The following list shows the <span class="T1">format</span> codes you can use for formatting a number:</p>
  43.   <p class="Paragraph">0 : If <span class="T1">Number</span> has a digit at the position of the 0 in the format code, the digit is displayed; otherwise a zero appears.</p>
  44.   <p class="Paragraph">If the <span class="T1">Number</span> expression has fewer digits than the number of zeros in the format code, (on either side of the decimal), leading or trailing zeros are displayed. If the number has more digits to the left of the decimal separator than the amount of zeros in the format code, the additional digits are displayed without modification.</p>
  45.   <p class="Paragraph">Decimal places of the number are rounded to the number of zeros in the <span class="T1">Format</span> code following the decimal separator.</p>
  46.   <p class="Paragraph"># : If Number contains a digit at the position of the # placeholder in the <span class="T1">Format</span> code, the digit is displayed; otherwise nothing is displayed at this position.</p>
  47.   <p class="Paragraph">This symbol works like the 0, except that leading or trailing zeroes are not displayed if there are more # characters in the format code than digits in the number. Only the relevant digits of the number are displayed.</p>
  48.   <p class="Paragraph">. : The decimal placeholder determines the number of decimal places to the left and right of the decimal separator.</p>
  49.   <p class="Paragraph">If the format code contains only # placeholders to the left of this symbol, numbers less than 1 begin with a decimal separator. To always display a leading zero with fractional numbers, use 0 as a placeholder for the first digit to the left of the decimal separator.</p>
  50.   <p class="Paragraph">% : The number is multiplied by 100. The percent sign (%) is inserted at the position where it appears in the format code.</p>
  51.   <p class="Paragraph">E- E+ e- e+ : If the format code contains at least one digit placeholder (0 or #) to the right of the symbol E-, E+, e-, or e+, the number is formatted in the scientific or exponential format. The letter E or e is inserted between the number and the exponent. The number of placeholders for digits to the right of the symbol determines the number of digits in the exponent.</p>
  52.   <p class="Paragraph">If the exponent is negative, a minus sign is displayed directly before an exponent with E-, E+, e-, e+. If the exponent is positive, a plus sign is only displayed before exponents with E+ or e+.</p>
  53.   <p class="Paragraph">, : The comma is a placeholder for the thousands separator. It separates thousands from hundreds in a number with at least four digits.</p>
  54.   <p class="Paragraph">The thousands delimiter is displayed if the format code contains the placeholder surrounded by digit placeholders (0 or #).</p>
  55.   <p class="Paragraph">- + $ ( ) space : A plus (+), minus (-), dollar ($), space, or brackets entered directly in the format code is displayed as a literal character.</p>
  56.   <p class="Paragraph">To display characters other than the ones listed here, you must precede it by a backslash (\), or enclose it in quotation marks (" ").</p>
  57.   <p class="Paragraph">\ : The backslash displays the next character in the format code.</p>
  58.   <p class="Paragraph">Characters in the format code that have a special meaning can only be displayed as literal characters if preceded by a backslash. The backslash itself is not displayed, unless you enter a double backslash (\\) in the format code.</p>
  59.   <p class="Paragraph">Characters that must be preceded by a backslash in the format code in order to be displayed as literal characters are the date- and time-formatting characters (a, c, d, h, m, n, p, q, s, t, w, y, /, :), numeric-formatting characters (#, 0, %, E, e, comma, period) and string-formatting characters (@, &, <, >, !).</p>
  60.   <p class="Paragraph">The use of the period as a thousands and decimal separator is dependent on the regional setting. The actual character displayed as a decimal separator depends on the <text:s text:c="" xmlns:text="http://openoffice.org/2000/text"/>number format in your system settings. The examples shown here assume that the regional setting is "US".</p>
  61.   <p class="Paragraph">The following predefined number formats can also be used. With the exception of "General Number", all format codes return the number as a decimal number with two decimal places.</p>
  62.   <p class="Paragraph">If you use predefined formats, the name of the format must be enclosed in quotation marks.</p>
  63.   <p class="P2">Predefined format</p>
  64.   <p class="Paragraph">General Number : Numbers are displayed as entered.</p>
  65.   <p class="Paragraph">Currency : A dollar sign is placed in front of the number; negative numbers are enclosed in parentheses.</p>
  66.   <p class="Paragraph">Fixed : At least one digit is displayed in front of the decimal separator.</p>
  67.   <p class="Paragraph">Standard : Displays numbers with a thousands separator.</p>
  68.   <p class="Paragraph">Percent : The number is multiplied by 100 and a percent sign is appended to the number.</p>
  69.   <p class="Paragraph">Scientific : Displays numbers in scientific format (e.g., 1,00E+03 for 1000).</p>
  70.   <p class="Paragraph">A format code can be divided into three sections, separated by semicolons. The first part defines the format for positive values, the second part for negative values, and the third part for zero. If only one format code is given, it applies to all numbers.</p>
  71.   <p class="P2">Example:</p>
  72.   <p class="PropText">Sub ExampleFormat</p>
  73.   <p class="PropText">MsgBox Format(6328.2, "##,##0.00") REM = 6,328.20</p>
  74.   <p class="PropText">End Sub</p>
  75.   <p class="PropText"/>
  76.  </body></html>